<?php

namespace plugin\admin\app\model;


use plugin\admin\app\model\Base;

/**
 * @property integer $id (主键)
 * @property integer $type 上门服务
 * @property integer $user_id 用户
 * @property string $sn 设备编号
 * @property string $channel 购买渠道
 * @property string $door_date 上门日期
 * @property string $start_time 开始时间
 * @property string $end_time 结束时间
 * @property string $desc 故障描述
 * @property string $img_src 现场图片
 * @property string $created_at 创建时间
 * @property string $updated_at
 */
class AfterSale extends Base
{
    /**
     * The table associated with the model.
     *
     * @var string
     */
    protected $table = 'wa_after_sales';

    /**
     * The primary key associated with the table.
     *
     * @var string
     */
    protected $primaryKey = 'id';

    public function attachments()
    {
        return $this->hasMany(Attachment::class, 'after_sale_id', 'id');
    }

    public function user()
    {
        return $this->belongsTo(User::class);
    }

    public function device()
    {
        return $this->belongsTo(Device::class, 'sn', 'sn');
    }
}
